/**
 * Created by hms on 2020-08-22.
 */
import UploadAPI from '../api/upload.js'

export const Upload={
    state:{
       image_url:''   //上传成功后图片url
    },
    mutations:{
       setImageUrl(state,url){
          state.image_url=url;
       }
    },
    actions:{
       uploadImage(context,data){
         UploadAPI.uploadImage(data).then(function(response){
              if(response.data.code==1){
                  context.commit('setImageUrl',response.data.url);
             }
         })
       }
    },
    getters:{
      getImageUrl: state =>{
        return this.image_url;
      }
    }
}
